class FireAxeWFireB extends AxeWFireB;

var array<sound>    ExplodeSounds;

simulated function Timer()
{
	local Actor HitActor;
	local vector StartTrace, EndTrace, HitLocation, HitNormal;
	local rotator PointRot;
	local int MyDamage;
	local KFPlayerReplicationInfo KFPRI;
	KFPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
	if( !KFWeapon(Weapon).bNoHit )
	{
		hitDamageClass=Class'PerksSimHostOrg.DamTypeAxeW'; //set back to default in case it was changed by a firebug doing a death from above attack :P
		MyDamage = MeleeDamage;
		if (KFPRI != none)
		{
			if (KFPRI.ClientVeteranSkill == Class'SRVetBerserker')
			{
				MyDamage=500 + Rand(120);
			}
		}
		StartTrace = Instigator.Location + Instigator.EyePosition();
		if( Instigator.Controller!=None && PlayerController(Instigator.Controller)==None && 
			Instigator.Controller.Enemy!=None )
		{
			PointRot = rotator(Instigator.Controller.Enemy.Location-StartTrace); // Give aimbot for bots.
		}
		else
		{
			PointRot = Instigator.GetViewRotation();
		}

		EndTrace = StartTrace + vector(PointRot)*weaponRange;
		HitActor = Instigator.Trace( HitLocation, HitNormal, EndTrace, StartTrace, true);

		if (HitActor!=None)
		{
			ImpactShakeView();

			if( HitActor.IsA('ExtendedZCollision') && HitActor.Base != none &&
				HitActor.Base.IsA('KFMonster') )
			{
				HitActor = HitActor.Base;
			}

			Weapon.Skins[SRKFMeleeGun(Weapon).BloodSkinSwitchArray] = SRKFMeleeGun(Weapon).BloodyMaterial;
			Weapon.texture = Weapon.default.Texture;


			if( (KFMonster(HitActor)!=none) || (KFHumanPawn(HitActor)!=none))
			{
				//special fx; happens on clients and listen server host
				if( Level.NetMode!=NM_DedicatedServer )
				{
					if (KFPRI != none)
					{
						if (KFPRI.ClientVeteranSkill == Class'SRVetFirebug')
						{
							Spawn(Class'KFIncendiaryExplosion',,, HitLocation, rotator(vect(0,0,1)));
							Spawn(Class'FireAxeWProj',Instigator, '', HitLocation, PointRot);
						}
						else if (KFPRI.ClientVeteranSkill == Class'SRVetBerserker')
							Spawn(Class'SChainsawWBloodExplosion',Instigator,, HitLocation, rotator(HitLocation - StartTrace));
					}
				}

				//only server deals the damage
				if( Level.NetMode==NM_Client )
				{
					return;
				}

				if (KFHumanPawn(HitActor)!=none)
					MyDamage = MyDamage / 4;
				else if( HitActor.IsA('Pawn') && !HitActor.IsA('Vehicle') && 
						(Normal(HitActor.Location-Instigator.Location) dot vector(HitActor.Rotation))>0 )
				{
					MyDamage*=2; // Backstab >:P
				}
			
				if (KFPRI != None)
				{
					if (KFPRI.ClientVeteranSkill == Class'SRVetBerserker')
						MyDamage *= 1.25; //bonus damage for falling strike
					else if (KFPRI.ClientVeteranSkill == Class'SRVetFirebug' && KFPRI.ClientVeteranSkillLevel > 10)
					{
						Spawn(Class'KFIncendiaryExplosion',,, HitLocation, rotator(vect(0,0,1)));
						Spawn(Class'FireAxeWProj',Instigator, '', HitLocation, PointRot);
					}
				}
				HitActor.TakeDamage(MyDamage, Instigator, HitLocation, vector(PointRot), hitDamageClass);
				if(MeleeHitSounds.Length > 0)
				{
					Weapon.PlaySound(MeleeHitSounds[Rand(MeleeHitSounds.length)],SLOT_None,MeleeHitVolume,,,,false);
				}

				if(VSize(Instigator.Velocity) > 300 && KFMonster(HitActor).Mass <= Instigator.Mass)
				{
					KFMonster(HitActor).FlipOver();
				}

			}
			else
			{
				HitActor.TakeDamage(MyDamage, Instigator, HitLocation, vector(PointRot), hitDamageClass) ;
				if (KFPRI.ClientVeteranSkill == Class'SRVetFirebug' && KFPRI.ClientVeteranSkillLevel > 10)
					Spawn(Class'FireAxeWProj',Instigator,'', HitLocation, rotator(HitLocation - StartTrace));
			}
			Weapon.ConsumeAmmo(ThisModeNum, AmmoPerFire);
		}
	}
}

defaultproperties
{
     ExplodeSounds(0)=SoundGroup'Inf_Weapons.antitankmine.antitankmine_explode01'
     ExplodeSounds(1)=SoundGroup'Inf_Weapons.antitankmine.antitankmine_explode02'
     ExplodeSounds(2)=SoundGroup'Inf_Weapons.antitankmine.antitankmine_explode03'
     MeleeHitSounds(0)=Sound'KFPawnDamageSound.MeleeDamageSounds.bathitflesh'
     MeleeHitSounds(1)=Sound'KFPawnDamageSound.MeleeDamageSounds.bathitflesh2'
     MeleeHitSounds(2)=Sound'KFPawnDamageSound.MeleeDamageSounds.bathitflesh3'
}
